<?php

namespace app\model;

use app\BaseModel;
use think\model\relation\BelongsTo;

/**
 * 量表题目因子关联表
 */
class RatingScaleQuestionRelatedFactorModel extends BaseModel
{
    protected $name = 'rating_scale_question_related_factor';

    /**
     * 新增数据验证
     * @return array
     */
    public function addValidate()
    {
        return [
            'rating_scale_id|量表id'  => 'require',
            'factor_id|因子表id'  => 'require',
        ];
    }

    /**
     * 关联量表题目-题号
     * @return BelongsTo
     */
    public function questionForNum(): BelongsTo
    {
        return $this->belongsTo(RatingScaleQuestionModel::class,'question_id')->bind(['num']);
    }

    /**
     * 关联量表因子
     * @return BelongsTo
     */
    public function factor(): BelongsTo
    {
        return $this->belongsTo(RatingScaleFactorModel::class,'factor_id');
    }

    /**
     * 关联量表因子名称
     * @return BelongsTo
     */
    public function factorName(): BelongsTo
    {
        return $this->belongsTo(RatingScaleFactorModel::class,'factor_id')->bind(['factor_name' => 'name']);
    }

    /**
     * 关联量表题目
     * @return BelongsTo
     */
    public function question(): BelongsTo
    {
        return $this->belongsTo(RatingScaleQuestionModel::class,'question_id');
    }

}